﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using DAL;

namespace BLL
{
   public partial class goodsManager
    {
       //根据货物ID获取信息
       public goods getBygoodsId(string goodsId)
       {
           return db.GetAll().Where(p => p.goodsId == goodsId).FirstOrDefault();
       }
       /// <summary>
       /// 根据货物名称获取信息
       /// </summary>
       /// <param name="goodsName"></param>
       /// <returns></returns>
       public goods getBygoodsName(string goodsName)
       {
           return db.GetAll().Where(p => p.goodsName == goodsName).FirstOrDefault();
       }

       //根据货物类型Id获取所有货物
       public IQueryable<goods> getByGoodsTypeId(string goodsTypeId)
       {
           return db.GetAll().Where(p => p.goodsTypeId == goodsTypeId);
       }
       //获取所有的货物编号
       public IQueryable<string> getgoodsId()
       {
           return db.GetAll().Select(p => p.goodsId);
       }
       //根据id删除货物
       public void delGoods(int id)
       {
           goods gs = db.GetAll().Where(p => p.id == id).FirstOrDefault();
           if (gs != null)
           {
               db.Delete(gs);
               db.SaveChanges();
           }
       }
    }
}
